package com.sunyur.tailor.channel.common.middle.util;

import com.sunyur.tailor.channel.common.middle.base.ChannelListResult;
import com.sunyur.tailor.channel.common.middle.enums.MiddleResultEnum;

import java.util.List;

/**
 *
 * @Description:返回工具类
 */
public class ChannelListResultUtil {

    private ChannelListResultUtil() {}

    /** *
     * @Description: 生成成功实体对象
     */
    public static final <T> ChannelListResult<T> success(List<T> model){
        ChannelListResult<T> result = new ChannelListResult<>();
        result.setCode(MiddleResultEnum.SUCCESS.getCode());
        result.setContent(model);
        return result;
    }

    /** *
     * @Description: 生成错误实体对象
     */
    public static final <T> ChannelListResult<T> error(String code, String message){
        ChannelListResult<T> result = new ChannelListResult<>();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }
}